﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace T2tk1
{
    class Program
    {
        static void Main(string[] args)
        {
            string conStr = "server=.;database=LIANg;Integrated Security=true";
            SqlConnection conn = new SqlConnection(conStr);
            conn.Open();

            if (conn.State==System.Data.ConnectionState.Open)
            {
                Console.WriteLine("连接成功！！！");
                string sqlStr = "select GameID,GameName,Price,Stock,Price * Stock from Games";
                SqlCommand cmd = new SqlCommand(sqlStr, conn);
                SqlDataReader dr = cmd.ExecuteReader();
                Console.WriteLine("序号\t\t游戏名称\t\t游戏价格\t\t库存数量\t\t小计");
                while (dr.Read())
                {
                    Console.WriteLine("{0}\t\t{1}\t\t￥{2}元\t\t{3}\t\t{4}", dr[0],dr[1],dr[2],dr[3],dr[4]);

                }
            }
            else
            {
                Console.WriteLine("连接失败！！！");
            }
            conn.Close();
        }
    }
}
